package com.atguigu.spzx.user.controller;

import com.atguigu.spzx.model.entity.base.Region;
import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.common.ResultCodeEnum;
import com.atguigu.spzx.user.service.RegionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @ClassName: RegionController
 * @Package: com.atguigu.spzx.user.controller
 * @Description 地区信息表
 * @Author 孤妤
 * @Date: 2023/12/22 11:37
 */
@Tag(name = "地区信息")
@RequestMapping("/api/user/region")
@RestController
public class RegionController {
    @Autowired
    private RegionService regionService;
    @Operation(summary = "查询地区信息")
    @GetMapping("/findByParentCode/{parentCode}")
    public Result findRegionByParentCode(@PathVariable(required = false) String parentCode){
        List<Region> regionList = regionService.findRegionByParentCode(parentCode);
        return Result.build(regionList, ResultCodeEnum.SUCCESS);
    }
}
